package nine;

import java.util.*;

    public class pp {
        public static void main(String[] args) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("c", "2019-03");
            map.put("a", "2018-12");
            map.put("b", "2019-01");
            map.put("d", "2019-02");

            List<Map.Entry<String, String>> list = new ArrayList<Map.Entry<String, String>>(map.entrySet());
            Collections.sort(list, new Comparator<Map.Entry<String, String>>() {
                //升序排序
                @Override
                public int compare(Map.Entry<String, String> o1,
                                   Map.Entry<String, String> o2) {
                    return o1.getValue().compareTo(o2.getValue());
                }

            });

            for (Map.Entry<String, String> mapping : list) {
                System.out.println(mapping.getKey() + ":" + mapping.getValue());
            }
        }
    }

